package com.group5.onlinegame.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.group5.onlinegame.dao.IRolesDao;
import com.group5.onlinegame.dao.IUserDao;
import com.group5.onlinegame.entity.Roles;
import com.group5.onlinegame.entity.User;
import com.group5.onlinegame.entity.UserRole;
import com.group5.onlinegame.entity.Vip;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.List;

@Service
public class UserService implements IUserService {

    @Resource
    private IUserDao iUserDao;
    @Resource
    private IRolesDao iRolesDao;
    @Override
    public PageInfo<User> getUserList(Integer pageNum,User user) {
        PageHelper.startPage(pageNum,5,"id desc");
        PageInfo<User> pageInfo=new PageInfo<>(iUserDao.getUserList(user));
        return pageInfo;
    }

    @Override
    public int delall(int[] id) {
        return iUserDao.delall(id);
    }

    @Override
    public int countUserByName(String username) {
        return iUserDao.countUserByName(username);
    }

    @Override
    public int delone(int id) {
        return iUserDao.delone(id);
    }

    @Override
    public List<Vip> getVipList() {
        return iUserDao.getVipList();
    }

    @Override
    public int adduser(User user) {
        return iUserDao.adduser(user);
    }

    @Override
    public User countUserById(int id) {
        return iUserDao.countUserById(id);
    }

    @Override
    public int editByid(User user) {
        return iUserDao.editByid(user);
    }

    @Override
    public Vip getVipById(Integer id) {
        return iUserDao.getVipById(id);
    }

    @Override
    public List<Roles> getUserListRoles() {
        return iRolesDao.getListRoles();
    }

    @Override
    public int adduserrole(UserRole userRole) {
        return iUserDao.adduserrole(userRole);
    }

    @Override
    public int getSeq() {
        return iUserDao.getSeq();
    }

    @Override
    public int editUserRoleById(UserRole userRole) {
        return iUserDao.editUserRoleById(userRole);
    }

    @Override
    public List<Timestamp> gettime() {
        return iUserDao.gettime();
    }

    @Override
    public int onoroff(User user) {
        return iUserDao.onoroff(user);
    }
}
